// 堆叠图
export const stacked = (that,containerId,entryData,midData,endData)=>{
  // 获取echarts容器 生成了echarts实例
  let myChart = that.$echarts.init(document.getElementById(containerId));
  let option = {
    title: {
      text: "成绩分析图",
    },
    tooltip: {
      trigger: "axis",
      extraCssText: "height:100px",
    },
    legend: {
      top: "10%",
      data: ["入学", "期中", "期末"],
    },
    grid: {
      top: "20%",
      left: "5%",
      right: "5%",
      bottom: "5%",
      containLabel: true,
    },
    toolbox: {
      feature: {
        saveAsImage: {},
      },
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: ["语文", "英语", "数学", "理综", "文综"],
    },
    yAxis: {
      type: "value",
    },
    series: [
      {
        name: "入学",
        type: "line",
        // stack: "Total",
        data: entryData,
      },
      {
        name: "期中",
        type: "line",
        // stack: "Total",
        data: midData,
      },
      {
        name: "期末",
        type: "line",
        // stack: "Total",
        data: endData,
      },
    ],
  };
  myChart.setOption(option);

  // 当希望echarts图随着屏幕的宽度的变化而变时
  //   前提是容器的宽和高不能给具体的px 给成百分比
  window.onresize = function () {
    myChart.resize();
  };
}

// 折线图
export const basisLine = (that,containerId,subject,gradeSubject)=>{
    // 获取echarts容器 生成了echarts实例
  let myChart = that.$echarts.init(document.getElementById(containerId));
  let option = {
    title: {
        text: subject,
      },
    xAxis: {
      type: 'category',
      data: ["入学","期中","期末"]
    },
    grid: {
        top: "20%",
        left: "5%",
        right: "5%",
        bottom: "5%",
        containLabel: true,
      },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: gradeSubject,
        type: 'line'
      }
    ]
  };
  myChart.setOption(option);

  // 当希望echarts图随着屏幕的宽度的变化而变时
  //   前提是容器的宽和高不能给具体的px 给成百分比
  window.onresize = function () {
    myChart.resize();
  };
}